<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>人员管理</title>
</head>

<body style="background-color: rgba(187, 179, 179, 0.38);" onload="loadMessageCount()">
<div class="container">
         <jsp:include page="header.jsp"/>
<h1 class="col-sm-12" style="font-family:迷你简菱心;"><strong>会议管理系统</strong></h1>
<br><br><br>
<div class="col-sm-2">
			<div data-spy="affix" data-offset-top="160" data-offset-bottom="0">
				<ul class="nav nav-pills nav-stacked">
					<li class="dropdown"><a class="dropdown-toggle"
						data-toggle="dropdown" href="#"> 我的会议<span class="caret"></span> </a>
						<ul class="dropdown-menu">
							<li><a href="myMeetingInfo.action#future7">未来7天内的会议</a></li>
							<li><a href="myMeetingInfo.action#myOrder">我预约的会议</a></li>
							<li><a href="myMeetingInfo.action#ended">已结束的会议</a></li>
							<li><a href="myMeetingInfo.action#cancel">已取消的会议</a></li>
						</ul>
					</li>

					<li class="dropdown"><a class="dropdown-toggle"
						data-toggle="dropdown" href="#"> 申请会议<span class="caret"></span>
					</a>
						<ul class="dropdown-menu">
							<li><a href="applyByTimeAndNumber.action">通过时间和容量</a>
							</li>
							<li><a href="applyMeetingByAddress.action">通过地点</a>
							</li>
						</ul>
					</li>
					<li><a href="personalInfo.action">
							个人信息</a>
					</li>
					<li><a href="getInvitationInfo.action">
							<span class="badge pull-right" id="mCount"></span>消息</a>
					</li>

				<c:if test="${sessionScope.adminFlag == '1'}">
						<li><a type="button" data-toggle="collapse" data-target="#admin">管理功能</a></li>
						</c:if>
				</ul>
				<div id="admin"  class="collapse in">
					<ul class="nav nav-pills nav-stacked">
						<li class="active"><a href="getPersonAction.action">人员管理</a>
						</li>
						<li><a href="GetMeetingRoomAction.action"><span
								class="badge pull-right"></span>会议室管理</a>
						</li>
						<li><a href="getDeviceAction.action"><span
								class="badge pull-right"></span>设备管理</a>
						</li>
						<li><a href="getDepartmentAction.action"><span
								class="badge pull-right"></span>部门管理</a>
						</li>
						<li><a href="GetMeetingAction.action"><span
								class="badge pull-right"></span>会议管理</a>
						</li>
					</ul>
				</div>
				<!-- 管理界面 -->
			</div>
			<!--  -->
		</div>
  <div class="col-sm-10">
  <ol class="breadcrumb">
  <li><a href="myMeetingInfo.action">主页</a></li>
  <li class="active">人员管理</li>
</ol>

<c:if test="${PmodisSuccess=='true'}">
 <div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  <strong>提示！</strong>信息修改成功！
</div>
</c:if>

<div class="panel panel-info">
  <div class="panel-heading col-sm-12">
					<h3 class="panel-title col-sm-2"
						style="margin-top: 10px;padding-left: 0px;">人员列表</h3>
					<div class="col-sm-8 pull-right">
					<form action="SearchPersonAction" method="post">
						<div class="input-group col-sm-6 pull-right">
							<input id="searchMes" name="searchMes" type="text" class="form-control " placeholder="请输入人员姓名">
							<div class="input-group-btn">
								<button type="submit" class="btn btn-default">
									<span class="glyphicon glyphicon-search"></span> 搜索
								</button>
							</div>
							<!-- /btn-group -->
						</div>
						<!-- /input-group -->
						</form>
					</div>
					<!-- /.col-lg-6 -->
				</div>
  <table class="table table-striped table-bordered" >

 <tr align="center" id="tr">
 <td>姓名</td>
 <td>性别</td>
 <td>部门</td>
 <td>电话</td>
 <td>职位</td>
  <td>注册码</td>
 <td>状态</td>
 
   <td>操作</td>
   
 </tr>
 
 <c:forEach items="${staffs}" var="staff">
 <tr align="center" id="${staff.SId}">
 <td>${staff.SName}</td>
 <td><c:if test="${staff.sex==0}">男</c:if><c:if test="${staff.sex==1}">女</c:if></td>
 <td>${staff.department.deName}</td>
 <td>${staff.phone}</td>
 <td>${staff.position}</td>
 <td class="hide">${staff.password}</td>
 <td class="hide">${staff.adminFlag}</td>
 <td class="hide">${staff.department.deId}</td>
 <td>${staff.reCode}</td>
 <td class="hide">${staff.state}</td>
 <td><c:choose>
<c:when test="${staff.state==0}"><span class="label label-info">审核中</span></c:when>
<c:when test="${staff.state==1}"><span class="label label-success">已审核</span></c:when>
<c:when test="${staff.state==2}"><span class="label label-danger">离职</span></c:when> 
</c:choose></td>
 <td><c:if test="${staff.state==0}"><a class="btn btn-default btn-xs" href="AgreePersonAction?id=${staff.SId}">
 同意</a></c:if>
 <c:if test="${staff.state==1}"><button type="button" class="btn btn-default btn-xs" disabled="disabled">已批</button></c:if>
 <c:if test="${staff.state==2}"><button type="button" class="btn btn-default btn-xs" disabled="disabled">离职</button></c:if>
 <button type="button" class="btn btn-success btn-xs"
 data-toggle="modal" data-target="#ModifyModal" onclick="getID(${staff.SId})">修改</button>
 <c:if test="${staff.state==1 || staff.state==0}">
 <a class="btn btn-danger btn-xs" href="DismissionPersonAction?id=${staff.SId}">离职</a>
 </c:if>
 <c:if test="${staff.state==2}">
 <a class="btn btn-info btn-xs" href="AgreePersonAction?id=${staff.SId}">复职</a>
 </c:if>
 <input type="text" class="hide" id="AMD" name="AMD">
 </td>
 </tr>
 </c:forEach>
</table>
<div align="center">
	<ul class="pager">
					<c:if test="${startpage != null}">
					<c:choose>
					<c:when test="${startpage-1<0}">
					<li class="disabled"><a href="#">上一页</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="getPersonAction.action?startpage=${startpage-1}">上一页</a></li>
					</c:otherwise>
					</c:choose>
					<c:choose>
					<c:when test="${(startpage+1)*6>account}">
					<li  class="disabled"><a href="#">下一页</a></li>
					</c:when>
					<c:when test="${account<=6}">
					<li  class="disabled"><a href="#">下一页</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="getPersonAction.action?startpage=${startpage+1}">下一页</a></li>
					</c:otherwise>
					</c:choose>
					</c:if>
	</ul>
</div>
</div>
</div>
</div>

<div class="modal fade" id="ModifyModal">
		<div class="modal-dialog">
			<div class="modal-content">
			<form action="ModifyPersonAction" method="post" id="modForm">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">用户信息</h4>
				</div>
				<div class="modal-body">
				<div class="row" style="margin-top:10px;margin-left: 50px;margin-right: 50px">
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
  						<input type="text" class="form-control" placeholder="姓名" id="Sname" name="Sname">
					</div>
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-home"></span></span>
  						<select class="form-control" id="Sdepment" name="Sdepment">
                            <c:forEach items="${depmes}" var="dep"> 
                            <option value="${dep.deId}">${dep.deName}</option>
                            </c:forEach>
                        </select>
					</div>
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-star"></span></span>
  						<input type="text" class="form-control" placeholder="职位" id="Spos" name="Spos">
					</div>
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-earphone"></span></span>
  						<input type="text" class="form-control" placeholder="电话" id="Spho" name="Spho">
					</div>
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
  						<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
  						<input type="text" class="form-control" placeholder="密码" id="Spas" name="Spas">
					</div>
					<div class="input-group input-group-xs" style="margin-bottom: 10px">
						<span class="input-group-addon"><span class="glyphicon glyphicon-adjust"></span></span>
						<select class="form-control" id="Ssex" name="Ssex">
                            <option value="0">男</option>
                            <option value="1">女</option>
                        </select>
					</div>
					<div class="input-group input-group-xs">
						<span class="input-group-addon"><span class="glyphicon glyphicon-eye-open"></span></span>
						<select class="form-control" id="Sman" name="Sman">
                            <option value="0">管理员</option>
                            <option value="1">非管理员</option>
                        </select>
					</div>
					<input type="text" class="hide" id="modID" name="modID">
					<input type="text" class="hide" id="modState" name="modState">
					<input type="text" class="hide" id="modRecode" name="modRecode">
				</div> 
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">确定</button>
				</div>
				</form>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
	
</body>
<script src="js/jquery-2.0.1.min.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript">

	function getID(Mid){
		var modState = document.getElementById("modState");
		var modRecode = document.getElementById("modRecode");
		var modID = document.getElementById("modID");
		var Sname = document.getElementById("Sname");
		var Sdepment =document.getElementById("Sdepment");
		var Spos = document.getElementById("Spos");
		var Spho = document.getElementById("Spho");
		var Spas = document.getElementById("Spas");
		var Ssex = document.getElementById("Ssex");
		var Sman = document.getElementById("Sman");
		var tr = document.getElementById(Mid);
		modID.value = Mid;
		
		Sname.value = tr.cells[0].innerHTML;
		if(tr.cells[1].innerHTML=="男"){
			Ssex.options[0].selected=true;
		}else{
			Ssex.options[1].selected=true;
		}
		for(i=0;i<Sdepment.options.length;i++){
			if(parseInt(Sdepment.options[i].value)==parseInt(tr.cells[7].innerHTML)){
				Sdepment.options[i].selected=true;
				break;
			}
		}
		Spho.value = tr.cells[3].innerHTML;
		Spos.value = tr.cells[4].innerHTML;
		Spas.value = tr.cells[5].innerHTML;
		if(tr.cells[6].innerHTML=="0"){
			Sman.options[0].selected=true;
		}
		else{
			Sman.options[1].selected=true;
		}
		modState.value = tr.cells[9].innerHTML;
		modRecode.value = tr.cells[8].innerHTML;
	}
	
	function loadMessageCount(){
		loadMessageCount_request = false;
		var url="getNewMessage.do";
		if(window.XMLHttpRequest){
			loadMessageCount_request = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){
			try{
				loadMessageCount_request=new ActiveXObject("Msxm12.XMLHTTP");
			}catch (e){
				try{
					loadMessageCount_request=new ActiveXObject("Microsoft.XMLHTTP");
				}catch (e){}
			}
		}
		if(!loadMessageCount_request){
			alert("不能创建X对象");
			return false;
		}
		loadMessageCount_request.onreadystatechange = function(){
			loadMes();
		};
		loadMessageCount_request.open('GET', url, true);
		loadMessageCount_request.send(null);
	}
	
	function loadMes(){
		if(loadMessageCount_request.readyState==4){
			if(loadMessageCount_request.status==200){
				var arr = loadMessageCount_request.responseText;
				var jsonss  =eval("("+arr+")");
				var mCount=document.getElementById("mCount");
				if(jsonss[0]!=0) mCount.innerHTML=jsonss[0];
				}//200
				
				}//4
			
	}//function
</script>
</html>